import Vue from 'vue'
import 'normalize.css'

import App from './App.vue'
import router from './router'
import store from './store'

import '@/utlis/vant'

Vue.config.productionTip = false
console.log(process.env)

import page from '@/utlis/page'
if (page.getAppTitle()) {
  store.commit('app/setTitle', page.getAppTitle())
}
store.commit('app/setFooter', page.getAppFooter())

const isAuthenticated = true
// GOOD
router.beforeEach((to, from, next) => {
  document.title = page.getAppTitle(to.meta.title)
  if (to.name !== 'Login' && !isAuthenticated) {
    next({ name: 'Login' })
  } else {
    next()
  }
})

new Vue({
  router,
  store,
  render: h => h(App)
}).$mount('#app')
